﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using FrienDev.BusinessRules;
using FrienDev.Data;
using System.Collections.Generic;

public partial class Controls_Users_RecentVisitorList : UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        List<User> myData;
        if (ApiHelper.Instance.IsFriendsPage())
        {
            IEnumerable<User> tempData = VisitorRules.Instance.GetRecentVisitorListByUserId(ApiHelper.Instance.GetRequestUserId(), 15);
            myData = tempData.ToList<User>();
            moreLink.Visible = false;
        }
        else
        {
            IEnumerable<User> tempData = VisitorRules.Instance.GetRecentVisitorListByUserId(UserRules.Instance.GetCurrentUserId(), 15);
            myData = tempData.ToList<User>();
        }
        DataList1.DataSource = myData;
        DataList1.DataBind();
        amount.Text = myData.Count().ToString();
    }
    protected void gridview_Load(object sender, EventArgs e)
    {
    }
    protected void hl_head_DataBinding(object sender, EventArgs e)
    {
        HyperLink hy = sender as HyperLink;
        hy.NavigateUrl = ApiHelper.Instance.GetUserHomepageLink(hy.NavigateUrl);
    }

    protected void isOnlineHandle(object sender, EventArgs e)
    {
        Image img = sender as Image;
        if (OnlineRules.Instance.IsUserOnline(img.ImageUrl))
        {
            img.ImageUrl = "/Images/online.gif";
        }
        else
        {
            img.Visible = false;
        }
    }
}
